package ao.com.bna.beans;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;


@Entity
@Table(name = "ItemRequisicao")
public class ItemRequisicao implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name = "ITEMREQUISICAO_ID_GENERATOR", sequenceName = "ITEMREQUISICAO_SEQ", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ITEMREQUISICAO_ID_GENERATOR")
	@Column(nullable = false, precision = 6)
	private Long id;

	@OneToOne
	@JoinColumn(name = "idPedido", referencedColumnName = "id", unique=true)
	private Pedido pedido = new Pedido();
	
    @ManyToOne
    @JoinColumn(name = "idRequisicao", referencedColumnName = "id", nullable = false)
	private Requisicao requisicao = new Requisicao();

	public ItemRequisicao() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	
	

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}




	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}




	/**
	 * @return the pedido
	 */
	public Pedido getPedido() {
		return pedido;
	}

	/**
	 * @param pedido the pedido to set
	 */
	public void setPedido(Pedido pedido) {
		this.pedido = pedido;
	}

	/**
	 * @return the requisicao
	 */
	public Requisicao getRequisicao() {
		return requisicao;
	}

	/**
	 * @param requisicao the requisicao to set
	 */
	public void setRequisicao(Requisicao requisicao) {
		this.requisicao = requisicao;
	}




	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}




	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ItemRequisicao other = (ItemRequisicao) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
	
	

}